<!--
 * @Author: whq
 * @Date: 2022-12-28 11:28:13
 * @LastEditTime: 2022-12-30 15:01:17
 * @LastEditors: whq
 * @Description: 
 * @FilePath: \vueTemp\src\view\components\A.vue
-->
<template>
    <div>
        子组件
        <el-input v-model="message"  placeholder="Please input" @input="changeInfo(message)" />
        <el-button type="primary" @click="emits('update:eventFun', '子组件事件触发')">子组件事件触发</el-button>
    </div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';

const emits = defineEmits(['update:test1','update:eventFun'])
const props = defineProps({
    // 父组件 v-model 没有指定参数名，则默认是 modelValue
    test1: {
        type: String,
        default: 'aaa'
    },
    eventFun: {
        type: Function,
        default: ()=>{}
    }
})
let message = ref('123')
// 数据双向绑定
const changeInfo = (info:any) => {
	emits('update:test1', info)
}

watch(()=> props.test1,() => {message.value = props.test1},{immediate:true})

</script>
<style lang="scss" scoped>

</style>